/****************************************************************************
**  FougTools
**  Copyright Fougue (30 Mar. 2015)
**  contact@fougue.pro
**
** This software is a computer program whose purpose is to provide utility
** tools for the C++ language and the Qt toolkit.
**
** This software is governed by the CeCILL-C license under French law and
** abiding by the rules of distribution of free software.  You can  use,
** modify and/ or redistribute the software under the terms of the CeCILL-C
** license as circulated by CEA, CNRS and INRIA at the following URL
** "http://www.cecill.info".
****************************************************************************/

#pragma once

#include "gui.h"

#include "../../cpptools/tree_bfs_explorer.h"

#include <QtGui/QStandardItem>
class QStandardItemModel;

namespace qtgui {

struct QStandardItemTreeBfsModel
{
    static bool isDeeper(const QStandardItem* current, const QStandardItem* previous);

    template<typename OUT_ITERATOR>
    static void enqueueChildren(OUT_ITERATOR out, QStandardItem* parentItem)
    {
        for (int row = 0; row < parentItem->rowCount(); ++row) {
            *out = parentItem->child(row);
            ++out;
        }
    }
};

class QTTOOLS_GUI_EXPORT QStandardItemExplorer :
        public cpp::TreeBfsExplorer<QStandardItem, QStandardItemTreeBfsModel>
{
public:
    QStandardItemExplorer();
    QStandardItemExplorer(QStandardItem* rootItem);
    QStandardItemExplorer(QStandardItemModel* model);
};

} // namespace qtgui
